<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8"> <![endif]-->
<!--[if !IE]><!-->
<html lang="zh">
<!--<![endif]-->
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path;
%>

<head>
    <meta charset="utf-8" />
    <title>保险代理后台管理系统</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport" />
    <meta content="" name="description" />
    <meta content="" name="author" />
    <!-- ================== BEGIN BASE CSS STYLE ================== -->
    <jsp:include page="../common/header.jsp"></jsp:include>
    <%@include file="../common/taglib.jsp"%>
    <!-- ================== END BASE CSS STYLE ================== -->

    <!-- ================== 单独作用于本页表格td ================== -->
    <!-- ================== 单独作用于本页表格td ================== -->
    <style type="text/css">
        img {
            cursor: pointer;
        }

        .control-label{width: 132px;}
        .col-md-9{width: 300px;}
    </style>
</head>
<body>
<!-- begin #page-loader -->
<div id="page-loader" class="fade in"><span class="spinner"></span></div>
<!-- end #page-loader -->

<!-- begin #page-container -->
<div id="page-container" class="fade page-sidebar-fixed page-header-fixed">
    <jsp:include page="../common/top.jsp"/>

    <!-- begin #sidebar -->
    <jsp:include page="../common/sitebar.jsp"/>
    <div class="sidebar-bg"></div>
    <!-- end #sidebar -->

    <!-- begin #content -->
    <div id="content" class="content">
        <div class="row">
            <!-- begin col-12 -->
            <div class="col-md-12">
                <!-- begin panel -->
                <div class="panel panel-inverse">
                    <div class="panel-heading">
                        <h4 class="panel-title">渠道编辑</h4>
                    </div>

                    <div class="panel-body">
                        <form action="/channel/updatePreChannel" method="POST" data-parsley-validate="true" name="form-wizard1" enctype="multipart/form-data" class="form-horizontal">
                            <input type="hidden" value="1" name="type" >
                            <input type="hidden" name="tid" value="${channel.tid}">
                            <div id="wizard2">
                                <ol>
                                    <li>
                                        个人信息
                                        <small></small>
                                    </li>
                                    <li>
                                        账户信息
                                        <small></small>
                                    </li>
                                    <li>
                                        附件
                                        <small></small>
                                    </li>
                                    <li>
                                        完成
                                        <small></small>
                                    </li>
                                </ol>
                                <!-- begin wizard step-1 -->
                                <div class="wizard-step-1 active in">
                                    <fieldset>
                                        <%--<legend class="pull-left width-full">Identification</legend>--%>
                                        <!-- begin row -->
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">姓名：</label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="contact.name" value="${channel.contact.name}"    data-parsley-required="true" data-parsley-legalpersonname="true" data-parsley-group="wizard-step-1" required
                                                       data-parsley-required-message="请输入姓名"  data-parsley-legalpersonname-message="姓名填写有误,请重新填写" data-parsley-maxlength="24" maxlength="24"  data-parsley-maxlength-message="姓名最长为24个字符" />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">身份证号: </label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="contact.idNo" value="${channel.contact.idNo}" data-parsley-required="true" data-parsley-legalpersonidno="true" data-parsley-group="wizard-step-1" required
                                                       data-parsley-required-message="请输入身份证号" data-parsley-legalpersonidno-message="身份证号填写有误,请重新填写" data-parsley-maxlength="18"  maxlength="18" data-parsley-maxlength-message="身份证号最长为18位" />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">工作单位：</label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="contact.companyName"  value="${channel.contact.companyName}" maxlength="30" data-parsley-group="wizard-step-1"
                                                       data-parsley-contactcompanyname="true" data-parsley-contactcompanyname-message="工作单位填写有误,请重新填写" data-parsley-maxlength="30" data-parsley-maxlength-message="工作单位最多为30位"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">入职时间：</label>
                                            <div class="col-md-3">
                                                <input type="text" class="form-control selectData" name="contact.entryDate" value="${channel.contact.entryDate}" />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">家庭住址：</label>

                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="homeAddress" value="${channel.contact.homeAddress}" data-parsley-required="true" data-parsley-homeaddress="true" data-parsley-group="wizard-step-1" required
                                                       data-parsley-required-message="请输入家庭住址"  data-parsley-homeaddress-message="家庭住址填写有误,请重新填写" data-parsley-maxlength="50" maxlength="50"  data-parsley-maxlength-message="家庭住址最多为50个字符"  />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">联系电话：</label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="contact.telephone"  value="${channel.contact.telephone}" maxlength="13" data-parsley-required="true" data-parsley-telephone="true" data-parsley-telephone-message="电话号码填写有误,请重新填写" data-parsley-required-message="请输入联系电话"
                                                       data-parsley-maxlength="13"  data-parsley-maxlength-message="联系电话最长为13位" data-parsley-group="wizard-step-1" required />
                                            </div>
                                        </div>
                                    </fieldset>
                                </div>
                                <!-- end wizard step-1 -->
                                <!-- begin wizard step-2 -->
                                <div class="wizard-step-2">
                                    <fieldset>
                                        <%--<legend class="pull-left width-full">Member Information</legend>--%>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">账户开户名：</label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="accountName"  value="${channel.accountName}"  data-parsley-accountname="true" data-parsley-accountname-message="账户开户名填写有误,请重新填写"
                                                       data-parsley-maxlength="20"  maxlength="20" data-parsley-maxlength-message="账户开户名最长为20个字符"  data-parsley-group="wizard-step-2"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">银行账号: </label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="accountNo" value="${channel.accountNo}" maxlength="20" data-parsley-accountno="true"   data-parsley-accountno-message="银行账号填写有误,请重新填写"
                                                       data-parsley-minlength="16" data-parsley-minlength-message="银行账号最短为16位"  data-parsley-maxlength="20"  data-parsley-maxlength-message="银行账号最长为20位" data-parsley-group="wizard-step-2" />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">所属银行：</label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="bankName" maxlength="20"  value="${channel.bankName}" data-parsley-maxlength="30" data-parsley-maxlength-message="所属银行最长为30个字符"
                                                       data-parsley-bankname="true" data-parsley-bankname-message="所属银行填写有误,请重新填写" data-parsley-group="wizard-step-2"/>
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">开户支行：</label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="bankBranchName"  value="${channel.bankBranchName}" data-parsley-bankbranchname="true" data-parsley-bankbranchname-message="开户支行填写有误,请重新填写"
                                                       maxlength="20"  data-parsley-maxlength="20" data-parsley-maxlength-message="开户支行最长为20位"  data-parsley-group="wizard-step-2" />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">支付宝账号：</label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="alipayNo" value="${channel.alipayNo}" maxlength="20" data-parsley-alipayno="true" data-parsley-alipayno-message="支付宝账号填写有误,请重新填写" data-parsley-group="wizard-step-2" />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">微信账号：</label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="weChatNo"   maxlength="20"  value="${channel.weChatNo}" data-parsley-group="wizard-step-2" data-parsley-wechatno="true" data-parsley-wechatno-message="微信账号填写有误,请重新填写"
                                                       data-parsley-minlength="6" data-parsley-minlength-message="微信账号最短为6位"  data-parsley-maxlength="20"  data-parsley-maxlength-message="微信账号最长为20位" />
                                            </div>
                                        </div>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">其它：</label>
                                            <div class="col-md-9">
                                                <input type="text" class="form-control" name="remark" maxlength="100" value="${channel.remark}"/>
                                            </div>
                                        </div>
                                        <%--<div class="form-group">
                                            <label class="col-md-3 control-label">系统登录名：</label>
                                            <div class="col-md-9">
                                                <input type="text" name="jobNumber" readonly="readonly" value="${sysUser.jobNumber}" class="form-control" maxlength="20"   data-parsley-only="true" data-parsley-only-message="该系统登录名已被使用"
                                                       data-parsley-minlength="6" data-parsley-minlength-message="系统登录名最短为6位"  data-parsley-maxlength="20"  data-parsley-maxlength-message="系统登录名最长为20位"/>
                                            </div>
                                        </div>--%>


                                    </fieldset>
                                </div>
                                <!-- end wizard step-2 -->
                                <!-- begin wizard step-3 -->
                                <div class="wizard-step-3">
                                    <div class="form-group" >
                                        <label class="col-md-4 control-label"><strong>附件名</strong></label>
                                        <div class="col-md-4">
                                            <label class="col-md-3 control-label"><strong>文件</strong></label>
                                        </div>
                                        <div class="col-md-4">
                                            <label class="col-md-3 control-label"><strong>操作</strong></label>
                                        </div>
                                    </div>
                                    <fieldset>
                                        <div class="form-group">
                                            <label class="col-md-3 control-label">身份证复印件：</label>
                                            <div class="col-md-3">
                                                <input name="contactsFile" type="file" data-parsley-filetype="true" data-parsley-group="wizard-step-3"
                                                     data-parsley-filetype-message="附件格式错误,请重新上传"  multiple>
                                            </div>
                                            <c:forEach items="${attachmentList}" var="attachment">
                                                <c:if test="${attachment.type == 6}">
                                                    <a href="#" onclick="viewPage('${attachment.url}')">${attachment.name}</a>
                                                    <img src="${ctx}/static/img/del.png" height="30" width="30" alt="删除" onclick="deleteFile('${attachment.tid}')">
                                                </c:if>
                                            </c:forEach>
                                        </div>
                                        <div class="form-group" style="display:none">
                                            <label class="col-md-3 control-label">营业执照：</label>
                                            <div class="col-md-9">
                                                <input name="businessLicenseFile" type="file">
                                            </div>
                                        </div>
                                        <div class="form-group" style="display:none">
                                            <label class="col-md-3 control-label">行业许可证：</label>
                                            <div class="col-md-9">
                                                <input name="industryLicenseFile" type="file">
                                            </div>
                                        </div>
                                        <div class="form-group" style="display:none">
                                            <label class="col-md-3 control-label">法人身份证：</label>
                                            <div class="col-md-9">
                                                <input name="legalPersonFile" type="file" multiple>
                                            </div>
                                        </div>
                                        <div class="form-group" style="display:none">
                                            <label class="col-md-3 control-label">高管身份证：</label>
                                            <div class="col-md-9">
                                                <input name="seniorManagerFile" type="file" multiple>
                                            </div>
                                        </div>
                                        <div class="form-group" style="display:none">
                                            <label class="col-md-3 control-label">实际控制人身份证：</label>
                                            <div class="col-md-9">
                                                <input name="actualControllerFile" type="file" multiple>
                                            </div>
                                        </div>
                                        <div id="addFile2" class="selectWrap" style="display:none">
                                            <div  class="form-group" >
                                                <%-- <label class="col-md-3 control-label">自定义附件名称：</label>--%>
                                                <input type="text"  class="col-md-3 control-label" name="alias" placeholder="自定义附件名称" />
                                                <div class="col-md-9">
                                                    <input type="hidden" name="fileType" value="6">
                                                    <input name="file"  type="file"   data-parsley-filetype="true" data-parsley-group="wizard-step-3" data-parsley-required-message="请上传身份证复印件"  data-parsley-filetype-message="附件格式错误,请重新上传"/>
                                                </div>
                                            </div><a href="javascript:;" onclick="delFile()" class="delFile">删除</a>
                                        </div>
                                        <div class="form-group" id="fileAdd2">
                                            <label class="col-md-3 control-label"></label>
                                            <div class="col-md-9">
                                                <a class="btn btn-sm btn-success" id="addFiles2"> + 添加附件</a>
                                            </div>
                                        </div>
                                    </fieldset>
                                </div>
                                <!-- end wizard step-3 -->
                                <!-- begin wizard step-4 -->
                                <div>
                                        <div class="jumbotron m-b-0 text-center">
                                            <i class="fa fa-2x fa-check-circle-o fa-4x text-warning"></i>
                                            <p class="h2">编辑完成</p>
                                            <button type="submit" class="btn btn-primary btn-lg">提交</button>
                                            <button type="button"  onClick="goBack()" class="btn btn-default btn-lg">取消</button>
                                        </div>
                                </div>
                                <!-- end wizard step-4 -->
                            </div>
                            <div class="form-group">
                                <label class="col-md-3 control-label">业务员：</label>
                                <div class="col-md-9">
                                    <%--  <input type="text" class="form-control" placeholder="Default input" />--%>
                                    <input type="hidden" class="form-control" id="userName" name="userName" value="${channel.masterUser.realName}">
                                        <select class="form-control input-lg" id="userId" name="userId" onchange="setName();" placeholder="业务员"  data-parsley-required="true"
                                                data-parsley-required-message="请选择业务员">
                                        <option value="">请选择</option>
                                        <c:forEach items="${list}" var="us">
                                            <option value="${us.tid}" <c:if test="${ us.tid == channel.masterUserId}"> selected="selected" </c:if>>${us.username}</option>
                                        </c:forEach>
                                    </select>
                                </div>
                            </div>
                        </form>
                    </div>
                    <!-- end panel -->
                </div>

            </div>
            <!-- end col-12 -->
        </div>
        <!-- end row -->
        <div class="modal fade" id="modal-subInfo">
            <div class="modal-dialog modal-sm">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                        <h4 class="modal-title">温馨提示</h4>
                    </div>
                    <div id="showSubInfo" class="modal-body">
                        当前填写内容未提交，确认取消？
                    </div>
                    <div class="modal-footer">
                        <a href="javascript:;" id="subButtonYes" class="btn btn-primary">确定</a>
                        <a href="javascript:;" id="subButtonNo" class="btn btn-default" data-dismiss="modal">取消</a>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- end #content -->

</div>
<!-- end page container -->
<jsp:include page="../common/footer.jsp"/>

<!-- ================== END PAGE LEVEL JS ================== -->


<script src="${ctx}/static/js/channel/channel_edit.js"></script>
<script>

    //时间插件配置
    $(".selectData").datepicker({
        autoclose: true, //自动关闭
        beforeShowDay: $.noop, //在显示日期之前调用的函数
        calendarWeeks: false, //是否显示今年是第几周
        clearBtn: false, //显示清除按钮
        daysOfWeekDisabled: [], //星期几不可选
        endDate: Infinity, //日历结束日期
        forceParse: true, //是否强制转换不符合格式的字符串
        format: 'yyyy-mm-dd', //日期格式
        keyboardNavigation: true, //是否显示箭头导航
        language: "zh-CN", //语言
        minViewMode: 0,
        orientation: "auto", //方向
        rtl: false,
        startDate: -Infinity, //日历开始日期
        startView: 0, //开始显示
        todayBtn: false, //今天按钮
        todayHighlight: true, //今天高亮
        weekStart: 0 //星期几是开始
    });

    window.ParsleyValidator.addValidator('legalpersonname', function(value) {
        if(value!= ""){
            return /^[a-zA-Z0-9\u4E00-\u9FA5]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('legalpersonidno', function(value) {
        if(value!= ""){
            return /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('contactcompanyname', function(value) {
        if(value!= ""){
            return /^[a-zA-Z0-9\u4E00-\u9FA5]+$/.test(value);
        }
        return true;
    },32);
    window.ParsleyValidator.addValidator('homeaddress', function(value) {
        if(value!= ""){
            return /^[\u4E00-\u9FA5A-Za-z\d\-]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('telephone', function(value) {
        if(value!= ""){
            var b = value.length;
            return (b == 11 &&  /^1\d{10}$/.test(value)) || (b >= 10 && b <= 13 && /^0\d{2}-\d+$/.test(value))
                || (b >= 10 && b <= 13 && /^0\d{3}-\d+$/.test(value) || (b >= 10 && b <= 13 && /^0\d{2}\d+$/.test(value)));
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('accountname', function(value) {
        if(value!= ""){
            return /^[a-zA-Z\u4e00-\u9fa5]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('accountno', function(value) {
        if(value!= ""){
            return /^[0-9]*$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('bankname', function(value) {
        if(value!= ""){
            return /^[a-zA-Z0-9\u4E00-\u9FA5]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('bankbranchname', function(value) {
        if(value!= ""){
            return /^[a-zA-Z0-9\u4E00-\u9FA5]+$/.test(value);
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('alipayno', function(value) {
        if(value!= ""){
            return( /^[a-zA-Z0-9]+$/.test(value) || /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/.test(value)) ;
        }
        return true;
    },32);

    window.ParsleyValidator.addValidator('wechatno', function(value) {
     if(value!= ""){
     return (/^[a-zA-Z][a-zA-Z0-9_-]{5,19}$/.test(value)|| /^[a-zA-Z0-9]+$/.test(value));
     }
     return true;
     },32);


    window.ParsleyValidator.addValidator('filetype', function(value) {
        if(value!= ""){
            return /\.(jpg|pdf|png|doc|docx|JPG|PDF|PNG|DOC|DOCX)$/.test(value);
        }
        return true;
    },32);





    //删除附件
    function delFile() {
            $(document).on('click', '.delFile', function () {
                $(this).closest('.selectWrap').remove();
            })
    }
    // 更多附件，新增附件
    $("#addFile").click(function(){
        var div = $("#addFile1");
        var clone = div.clone().show();
        var fileAdd = $("#fileAdd");
        clone.insertBefore(fileAdd);
    });
    // 更多附件，新增附件
    $("#addFiles2").click(function(){
        var div = $("#addFile2");
        var clone = div.clone().show();
        var fileAdd2 = $("#fileAdd2");
        clone.insertBefore(fileAdd2);
    });

    //去往编辑页面
    function toedit(id){
        window.location.href="<%=path%>/sysuser/toedit/"+id;
    }
    function toRefresh(){
        window.location.href="<%=path%>/channel/tolist/P";
    }

    //去往新增页面
    function toadd(){
        window.location.href="<%=path%>/sysuser/toadd";
    }

    function goBack(){
        $("#showSubInfo").html(" 当前填写内容未提交，确认取消？");
        $("#subButtonYes").attr("onclick","toRefresh();");
        $("#modal-subInfo").modal('show');
    }

    function showInfo(){
        $("#showSubInfo").html("确定要提交吗？");
        $("#subButtonYes").attr("onclick","submitInfos()");
        $("#infoModal").modal('show');
    }

    function submitInfos(){
        $("#subButtonYes").removeAttr("onclick");
        $("#infoModal").modal('hide');
        $("#submitForm").ajaxSubmit({
            type: "POST",
            url:"/channel/save",
            success: function(data){
                if(data.type =="S"){
                    $("#showSubInfo").html(data.message);
                    $("#subButtonYes").attr("onclick","reload()");
                    $("#infoModal").modal('show');
                }else{
                    $("#showSubInfo").html(data.message);
                    $("#infoModal").modal('show');
                }
            }
        });
    }

</script>
</body>
</html>
